package com.hxht.cmp.controller;

import com.hxht.cmp.common.enums.ResultCode;
import com.hxht.cmp.common.result.ResultResponse;
import com.hxht.cmp.service.CaseReviewService;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by gaozikun on 2017/7/20 0020.
 */
@RestController
@RequestMapping("caseCount")
public class CaseCountController {

    @Resource
    private CaseReviewService caseReviewService;

    /**
     * 开庭次数统计
     *
     * @param courtUid
     * @param caseType
     * @param startDate
     * @param endDate
     * @param status    0表示单个法院的统计
     * @return
     */
    @RequestMapping("getCaseCount")
    public ResultResponse getCaseCount(String courtUid, String caseType, String startDate, String endDate, String status) {
        if (ObjectUtils.isEmpty(courtUid) || ObjectUtils.isEmpty(status)) {
            return ResultResponse.failed(ResultCode.PARAMETER_NULL);
        }
        return ResultResponse.success(caseReviewService.getCaseCount(courtUid, caseType, startDate, endDate, status));
    }

    /**
     * 开庭时长统计
     *
     * @param courtUid
     * @param caseType
     * @param startDate
     * @param endDate
     * @param status
     * @return
     */
    @RequestMapping("getCaseTimeCount")
    public ResultResponse getCaseTimeCount(String courtUid, String caseType, String startDate, String endDate, String status) {
        if (ObjectUtils.isEmpty(courtUid) || ObjectUtils.isEmpty(status)) {
            return ResultResponse.failed(ResultCode.PARAMETER_NULL);
        }
        return ResultResponse.success(caseReviewService.getCaseTimeCount(courtUid, caseType, startDate, endDate, status));
    }

    /**
     * 开庭准点率统计
     *
     * @param courtUid
     * @param startDate
     * @param endDate
     * @param status
     * @return
     */
    @RequestMapping("getOnTimeCount")
    public ResultResponse getOnTimeCount(String courtUid, String startDate, String endDate, String status) {
        if (ObjectUtils.isEmpty(courtUid) || ObjectUtils.isEmpty(status)) {
            return ResultResponse.failed(ResultCode.PARAMETER_NULL);
        }
        return ResultResponse.success(caseReviewService.getOnTimeCount(courtUid, startDate, endDate, status));
    }

    /**
     * 获取案件类型，service写死
     *
     * @return
     */
    @RequestMapping("getAllCaseType")
    public ResultResponse getAllCaseType() {
        return ResultResponse.success(caseReviewService.getAllCaseType());
    }

    /**
     * 获取准点类型，service写死
     *
     * @return
     */
    @RequestMapping("getAllOnTimeType")
    public ResultResponse getAllOnTimeType() {
        return ResultResponse.success(caseReviewService.getAllOnTimeType());
    }

    /**
     * 获取法院案件对应的所有法官和书记员
     *
     * @param courtUid
     * @return
     */
    @RequestMapping("getJudgeAndSecretary")
    public ResultResponse getJudgeAndSecretary(String courtUid) {
        if (ObjectUtils.isEmpty(courtUid)) {
            return ResultResponse.failed(ResultCode.PARAMETER_NULL);
        }
        return ResultResponse.success(caseReviewService.selectJudgeAndSecretary(courtUid));
    }

    @RequestMapping("getTechnologyCourtRate")
    public ResultResponse technologyCourtRate(String courtUid) {
        if (ObjectUtils.isEmpty(courtUid)) {
            return ResultResponse.failed(ResultCode.PARAMETER_NULL);
        }
        return ResultResponse.success(caseReviewService.getTechnologyCourtRate(courtUid));
    }

}
